
/*--------------------- include file -------------------*/
#include "stm8s.h"
#include "..\include\Cpu_Pin_Configuration.h"
#include "..\include\Global_Decleration.h"

#include "..\include\Core_Initialize.h"
#include "..\include\Lcd_Driver.h"
#include "..\include\Global_Functions.h"

#include "stm8s_flash.h"

static void CORE_inputGpioInitialize(void)
{
	GPIO_Init(GPIOB, GPIOB_INPUT_PIN, GPIO_MODE_IN_PU_IT);
	GPIO_Init(GPIOC, GPIOC_INPUT_PIN, GPIO_MODE_IN_PU_IT);
	GPIO_Init(GPIOD, GPIOD_INPUT_PIN, GPIO_MODE_IN_PU_IT);
	GPIO_Init(GPIOE, GPIOE_INPUT_PIN, GPIO_MODE_IN_PU_IT);	
}

static void CORE_outputGpioInitialize(void)
{
	GPIO_Init(LCD_BL_PWR_PORT, LCD_BL_PWR_PIN, GPIO_MODE_OUT_PP_LOW_SLOW);
	GPIO_Init(LCD_PORT, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_MODE_OUT_PP_LOW_SLOW);
	GPIO_Init(LCD_CONTROL_PORT, GPIO_PIN_6 | GPIO_PIN_7, GPIO_MODE_OUT_PP_LOW_SLOW);
}

void CORE_initalizeAllGpio (void)
{

	CORE_inputGpioInitialize();
	CORE_outputGpioInitialize();	
}

/*
void configurationFlashToWriteRead(void)
{
	FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);
	FLASH_Unlock(FLASH_MEMTYPE_DATA);	
}

*/














/*
void Sistem_Clock_Kurulum (void)
{
  CLK_HSICmd(ENABLE);
  CLK_SYSCLKConfig()

  CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);//internal high speed clock
	
	CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_4);
	
	CLK_SYSCLKSourceSwitchCmd(ENABLE);
	
	while (CLK_GetSYSCLKSource() != CLK_SYSCLKSource_HSI);
	
		CLK_LSEConfig(CLK_LSE_ON);
	
	 Wait for LSE clock to be ready 
 	while (CLK_GetFlagStatus(CLK_FLAG_LSERDY) == RESET);
	
	 Select LSE (32.768 KHz) as RTC clock source 
	CLK_RTCClockConfig(CLK_RTCCLKSource_LSE, CLK_RTCCLKDiv_1);
	
	 Enable RTC clock 
	CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);

}*/





